package com.ylx.excel.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ylx.excel.excel.model.CapTypeImport;
import com.ylx.excel.mapper.AcAppCapTypeMapper;
import com.ylx.excel.model.AcAppCapType;
import com.ylx.excel.service.IAcAppCapTypeService;
import com.ylx.excel.utils.ExcelUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 能力初始化表 服务实现类
 * </p>
 *
 * @author yanglixin
 * @since 2024-07-09
 */
@Slf4j
@Service
public class AcAppCapTypeServiceImpl extends ServiceImpl<AcAppCapTypeMapper, AcAppCapType> implements IAcAppCapTypeService {

    @Override
    public void testCreate() {
        List<CapTypeImport> importList = ExcelUtils.importClassPathResourceExcel("能力表.xlsx", CapTypeImport.class);
        List<AcAppCapType> capTypeList = new ArrayList<>();
        for (CapTypeImport data : importList) {
            AcAppCapType acAppCapType = BeanUtil.copyProperties(data,AcAppCapType.class);
            capTypeList.add(acAppCapType);
        }
        this.saveBatch(capTypeList);
        for (AcAppCapType acAppCapType : capTypeList) {
            log.info("id: {}新增一条数据： {}",acAppCapType.getId(), JSON.toJSONString(acAppCapType));
        }
    }
}
